package glb;

import org.junit.Test; 
import robocode.ScannedRobotEvent;
import static org.junit.Assert.*;
/**
 * Tests that Failbot's toTurn() method functions correctly.
 * This method is used in targeting.
 * @author Gregory Burgess
 */
public class TestAim { 

  /**
   * Test Failbot's getPow() method by handing it specifically parameterized events.
   */
  @Test
  public void test() { 
    Failbot bot = new Failbot();
    //parameters for the event
    String name = "Bot";
    double energy = 100, distance = 199;
    double heading = 0, velocity = 4;
    double test = 0;
    
    //create the event
    ScannedRobotEvent e = new ScannedRobotEvent(name,energy,Math.toRadians(20),
        distance,heading,velocity);
    //call the method with the event
    //simple case were facing forward, with gun forward
    //enemy to the right
    test = bot.toTurn(e,1,1);
    assertEquals(test,20,0);
    System.out.println("1 Passed");
    
    //we're facing off center, gun facing north
    //enemy to the right
    e = new ScannedRobotEvent(name,energy,Math.toRadians(90),distance,heading,velocity);
    test = bot.toTurn(e,0,15);
    assertEquals(test,75,0);
    System.out.println("2 Passed");
    
    //were facing off center, gun is further off center
    //enemy is to the left
    e = new ScannedRobotEvent(name,energy,Math.toRadians(-90),distance,heading,1.0);
    test = bot.toTurn(e,9,15);
    assertEquals(test,-96,0);
    System.out.println("3 Passed");
    
    //facing off center, gun facing north
    //enemy to the rear-left
    e = new ScannedRobotEvent(name,energy,Math.toRadians(180),400,heading,velocity);
    test = bot.toTurn(e,10,0);
    assertEquals(test,-170,0);
    System.out.println("4 Passed");
  }

}
